//declare parameter pin
int doorLock=9;
int lamp=10;
int doorState=11;

void setup(){
  //setup for read input character command
  Serial.begin(9600);
  //configure input/output
  pinMode(doorLock,OUTPUT); 
  pinMode(lamp,OUTPUT);
  pinMode(doorState,INPUT);

}

void loop(){
  if (Serial.available()) {
    char remote = Serial.read(); //input the character commands 'L' or 'U'
    
    //analyse the input command respect to the case
    switch (remote) {
      //remote input 'L' to lock the door
      case 'L':
      //if the door is closed
      if(digitalRead(doorState)==HIGH){
        digitalWrite(doorLock,HIGH); //LED light up to state the door is locked
        digitalWrite(lamp,HIGH); //lamp blinking 1 second
        delay(1000);
        digitalWrite(lamp,LOW);
      }
      //if the door is opened
      else{
        Serial.println("door is open"); //nothing can do with a car
      }

      break;
      
      //remote input 'U' to unlock the door
      case 'U':
      //if the door is closed
      if(digitalRead(doorState)==HIGH){
        digitalWrite(doorLock,LOW); //LED not light up state the door is unlock
        digitalWrite(lamp,HIGH); //lamp blinking twice
        delay(1000);
        digitalWrite(lamp,LOW);
        delay(1000);
        digitalWrite(lamp,HIGH);
        delay(1000);
        digitalWrite(lamp,LOW);
      }
      //if the door is opened
      else{
        Serial.println("door is open"); //nothing can do with a car
      }
      
      break;
    }
  }
}
      

